package com.mioto.ld.module.knowledge.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.mioto.ld.module.knowledge.model.KnowledgeBasePagerVO;
import com.mioto.ld.module.knowledge.model.KnowledgeBaseStatus;
import com.mioto.ld.utils.BaseUtil;
import org.springframework.stereotype.Service;

import com.mioto.ld.module.knowledge.dao.KnowledgeBaseDao;
import com.mioto.ld.module.knowledge.model.KnowledgeBase;
import com.mioto.ld.module.knowledge.service.IKnowledgeBaseService;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 *
 * @author mioto
 * @date 2024-05-14 19:19:36
 */
@Service("knowledgeBaseService")
public class KnowledgeBaseServiceImpl implements IKnowledgeBaseService{

    @Resource
    private KnowledgeBaseDao knowledgeBaseDao;

    @Override
    public List<KnowledgeBase> findList(KnowledgeBase knowledgeBase) {
        return knowledgeBaseDao.findList(knowledgeBase);
    }

    @Override
    public List<KnowledgeBasePagerVO> findPager(KnowledgeBase knowledgeBase) {
        return knowledgeBaseDao.findPager(knowledgeBase);
    }

    @Override
    public int insert(KnowledgeBase knowledgeBase) {
        if (ObjectUtil.equal(knowledgeBase.getStatus(), KnowledgeBaseStatus.KNOWLEDGE_BASE_STATUS_PUBLISH)){
            knowledgeBase.initCreateData();
        }
        return knowledgeBaseDao.insertIgnoreNull(knowledgeBase);
    }

    @Override
    public int update(KnowledgeBase knowledgeBase) {
        return knowledgeBaseDao.update(knowledgeBase);
    }

    @Override
    public int updateIgnoreNull(KnowledgeBase knowledgeBase) {
        if (ObjectUtil.isNotNull(knowledgeBase.getStatus())){
            knowledgeBase.initCreateData();
        }
        return knowledgeBaseDao.updateIgnoreNull(knowledgeBase);
    }

    @Override
    public KnowledgeBase findByColumn(String column, Object value) {
        return knowledgeBaseDao.findByColumn(column,value);
    }

    @Override
    public int deleteByColumn(String column, Object value) {
        return knowledgeBaseDao.deleteByColumn(column,value);
    }

    @Override
    public int batchDelete(Integer[] ids) {
        return knowledgeBaseDao.batchDelete(ids);
    }

    @Override
    public List<KnowledgeBase> batchFind(Integer[] ids) {
        return knowledgeBaseDao.batchFind(ids);
    }
}